<button nz-button nzType="primary" (click)="open()">批量上传</button>

<nz-modal [(nzVisible)]="visible" nzTitle="CSV 批量上传" (nzOnCancel)="cancel()" (nzOnOk)="confirmUpload()">
  <ng-container *nzModalContent>
    <div class="upload-body">
      <label for="csvFile">上传 CSV 文件：</label>
      <div class="file-row">
        <input id="csvFile" type="text" [value]="fileName" readonly placeholder="请选择 CSV 文件" />
        <label class="browse-btn" nz-button nzType="default">
          浏览
          <input type="file" accept=".csv,text/csv" (change)="onFileSelected($event)" style="display:none" />
        </label>
        <button nz-button nzType="link" (click)="downloadTemplate()">模板下载</button>
      </div>

      <div *ngIf="parsedRows && parsedRows.length" class="preview">
        <h4>预览（前 5 行）</h4>
        <table>
          <thead>
            <tr>
              <th *ngFor="let h of parsedRows[0]">{{h}}</th>
            </tr>
          </thead>
          <tbody>
            <tr *ngFor="let row of parsedRows.slice(1,6)">
              <td *ngFor="let cell of row">{{cell}}</td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
  </ng-container>
</nz-modal>
